Skip to content

feat: migrate to Node 24 LTS#481

Merged
marcoscaceres merged 9 commits into
mainfrom
feat/node24-migration
Apr 15, 2026
Merged

feat: migrate to Node 24 LTS#481
marcoscaceres merged 9 commits into
mainfrom
feat/node24-migration

Conversation

@marcoscaceres

Copy link
Copy Markdown
Collaborator

Closes #373

Summary

  • Bumps .nvmrc and CI to Node 24 LTS
  • Adds "engines": { "node": ">=24" } to package.json
  • Removes node-fetch dependency — replaced with the Node 24 built-in fetch
  • Replaces legacyDirname(import.meta) / legacyFilename(import.meta) helpers (and their fileURLToPath plumbing) with import.meta.dirname / import.meta.filename (available since Node 21.2)
  • Deletes the now-unused legacyDirname and legacyFilename exports from utils/misc.ts
  • Fixes pre-existing Express 5 req.params type errors (TS2345) in commits.ts, contributors.ts, and group.ts
  • Adds tests verifying fetch, import.meta.dirname, and import.meta.filename are available as globals, and that PROJECT_ROOT resolves correctly

Note

This PR touches some of the same files as #480 (the security hardening PR). It should be merged after #480 to avoid conflicts.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates the service to Node.js 24 LTS, leveraging newer Node runtime features (built-in fetch, import.meta.dirname/import.meta.filename) and removing now-unneeded compatibility helpers/dependencies.

Changes:

  • Bump runtime/CI expectations to Node 24 (.nvmrc, GitHub Actions, package.json#engines).
  • Replace node-fetch and legacy import.meta path helpers with Node’s built-in fetch and import.meta.dirname/import.meta.filename.
  • Adjust Express 5 route param typing and add tests for Node 24 globals and PROJECT_ROOT.

Reviewed changes

Copilot reviewed 19 out of 20 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
utils/misc.ts Removes legacy dirname/filename helpers and related imports.
utils/constants.ts Uses import.meta.dirname to compute PROJECT_ROOT.
utils/background-task-queue.ts Switches worker bootstrap path to import.meta.filename.
scripts/update-w3c-groups-list.ts Drops node-fetch/fileURLToPath usage; uses global fetch and import.meta.filename.
app.ts Uses import.meta.dirname for views path.
routes/xref/update.ts Uses import.meta.dirname for worker path.
routes/caniuse/update.ts Uses import.meta.dirname for worker path.
routes/well-known/pay.ts Removes node-fetch import (uses global fetch).
routes/w3c/group.ts Adjusts Express 5 param typing; sets plain-text content type on invalid type.
routes/github/commits.ts Adjusts Express 5 param typing and query typing; ensures plain-text in error path.
routes/github/contributors.ts Adjusts Express 5 param typing.
routes/github/lib/utils/rest.ts Removes node-fetch types; adds GitHub API URL validation; updates header typing.
routes/github/lib/utils/graphql.ts Removes node-fetch import (uses global fetch).
routes/docs/update.ts Removes node-fetch import (uses global fetch).
tests/node24-globals.test.js Adds test assertions for Node 24 globals (fetch, import.meta.dirname, import.meta.filename).
tests/utils/constants.test.js Adds coverage for PROJECT_ROOT resolution.
package.json Adds Node >=24 engines constraint; removes node-fetch dependency.
pnpm-lock.yaml Removes node-fetch and its transitive dependencies.
.nvmrc Updates local Node version to 24.
.github/workflows/test.yml Adds/updates CI to run on Node 24.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (1)

routes/github/lib/utils/rest.ts:53

  • x-ratelimit-reset is a Unix timestamp in seconds, but new Date(number) expects milliseconds. As written, resetAt will be ~1000× earlier than intended, which can break any rate-limit/backoff logic that relies on resetAt. Convert the header value to milliseconds before constructing the Date.
function getRateLimit(headers: Headers): RateLimit {
  return {
    remaining: parseInt(headers.get("x-ratelimit-remaining") as string, 10),
    resetAt: new Date(parseInt(headers.get("x-ratelimit-reset") as string, 10)),
    limit: parseInt(headers.get("x-ratelimit-limit") as string, 10),

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/test.yml Outdated
Comment thread routes/github/commits.ts Outdated
Comment thread routes/github/commits.ts
Comment thread routes/github/contributors.ts Outdated
Comment thread routes/w3c/group.ts Outdated
Comment thread .github/workflows/test.yml Outdated
Comment thread .github/workflows/test.yml Outdated
Comment thread .github/workflows/test.yml Outdated
Comment thread routes/github/commits.ts Outdated
Comment thread scripts/update-w3c-groups-list.ts Outdated
@marcoscaceres

Copy link
Copy Markdown
Collaborator Author

@copilot, see @sidvishnoi's suggestions. Can you make the changes and also rebase?

Copilot AI commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

@copilot, see @sidvishnoi's suggestions. Can you make the changes and also rebase?

Applied @sidvishnoi’s suggestions in eb69200 (workflow action versions, required from query typing, and import.meta.main). Branch is synchronized with origin/feat/node24-migration.

@marcoscaceres

Copy link
Copy Markdown
Collaborator Author

@copilot Can you fix the ci issue?

Copilot AI commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

@copilot Can you fix the ci issue?

Fixed in 6d88026: I added a TypeScript ambient declaration for ImportMeta.main in @types/import-meta.d.ts, which addresses the CI build failure (TS2339 in scripts/update-w3c-groups-list.ts).

Comment thread @types/import-meta.d.ts

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does some lib in tsconfig not support it? Or updating @types/node?
Fine this way as well.

@marcoscaceres
marcoscaceres merged commit 373ce24 into main Apr 15, 2026
3 checks passed
@marcoscaceres
marcoscaceres deleted the feat/node24-migration branch April 15, 2026 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate to Node 24

4 participants